// tools/generate_alphabets.dart
import 'dart:convert';
import 'dart:io';

void main() {
  final alphabets = <Map<String, dynamic>>[];
  for (var i = 0; i < 26; i++) {
    final letter = String.fromCharCode(65 + i);
    final lowercase = letter.toLowerCase();
    alphabets.add({
      'letter': letter,
      'imagePath': 'assets/letters/${lowercase}_icon.png',
      'audioPath': 'assets/sounds/letters/${lowercase}.mp3',
      'phonetic': _getPhonetic(letter),
      'examples': _getExamples(letter),
    });
  }

  File('assets/data/alphabets.json')
    .writeAsStringSync(jsonEncode(alphabets));
}

String _getPhonetic(String letter) {
  // 返回字母的音标
  final phonetics = {
  'A': '/eɪ/',   // A
  'B': '/biː/',  // B
  'C': '/siː/',  // C
  'D': '/diː/',  // D
  'E': '/iː/',   // E
  'F': '/ɛf/',   // F
  'G': '/dʒiː/',  // G
  'H': '/eɪtʃ/',  // H
  'I': '/aɪ/',   // I
  'J': '/dʒeɪ/',  // J
  'K': '/keɪ/',  // K
  'L': '/ɛl/',   // L
  'M': '/ɛm/',   // M
  'N': '/ɛn/',   // N
  'O': '/oʊ/',   // O
  'P': '/piː/',  // P
  'Q': '/kjuː/', // Q
  'R': '/ɑːr/',  // R
  'S': '/ɛs/',   // S
  'T': '/tiː/',  // T
  'U': '/juː/',  // U
  'V': '/viː/',  // V
  'W': '/ˈdʌbəl.juː/', // W
  'X': '/ɛks/',   // X
  'Y': '/waɪ/',   // Y
  'Z': '/ziː/'    // Z
};
  return phonetics[letter] ?? '';
}

List<String> _getExamples(String letter) {
  // 返回包含该字母的单词示例
 final examples = {
  'A': ['Apple - 🍎', 'Ant - 🐜', 'Airplane - ✈️'],
  'B': ['Ball - ⚽', 'Banana - 🍌', 'Bear - 🐻'],
  'C': ['Cat - 🐱', 'Car - 🚗', 'Cup - ☕'],
  'D': ['Dog - 🐶', 'Dolphin - 🐬', 'Duck - 🦆'],
  'E': ['Elephant - 🐘', 'Egg - 🥚', 'Eagle - 🦅'],
  'F': ['Fish - 🐟', 'Frog - 🐸', 'Flower - 🌸'],
  'G': ['Giraffe - 🦒', 'Guitar - 🎸', 'Gift - 🎁'],
  'H': ['House - 🏠', 'Hat - 🧢', 'Horse - 🐴'],
  'I': ['Ice cream - 🍦', 'Igloo - 🏔️', 'Island - 🏝️'],
  'J': ['Juice - 🥤', 'Jaguar - 🐆', 'Jellyfish - 🦠'],
  'K': ['Kite - 🪁', 'Koala - 🐨', 'Key - 🔑'],
  'L': ['Lion - 🦁', 'Lamp - 💡', 'Leaf - 🍃'],
  'M': ['Monkey - 🐒', 'Mango - 🥭', 'Moon - 🌙'],
  'N': ['Nurse - 👩‍⚕️', 'Nest - 🐦', 'Notebook - 📓'],
  'O': ['Owl - 🦉', 'Orange - 🍊', 'Octopus - 🐙'],
  'P': ['Penguin - 🐧', 'Pizza - 🍕', 'Panda - 🐼'],
  'Q': ['Queen - 👸', 'Quilt - 🛏️', 'Quokka - 🐨'],
  'R': ['Rabbit - 🐰', 'Rainbow - 🌈', 'Robot - 🤖'],
  'S': ['Sun - ☀️', 'Star - ⭐', 'Snake - 🐍'],
  'T': ['Tiger - 🐅', 'Tree - 🌳', 'Turtle - 🐢'],
  'U': ['Umbrella - ☂️', 'Unicorn - 🦄', 'Uniform - 🎽'],
  'V': ['Violin - 🎻', 'Vase - 🏺', 'Volcano - 🌋'],
  'W': ['Whale - 🐋', 'Windmill - 🌬️', 'Watermelon - 🍉'],
  'X': ['Xylophone - 🎼', 'X-ray - 🦴', 'Xmas tree - 🎄'], // X 可能不常用
  'Y': ['Yacht - ⛵', 'Yogurt - 🍦', 'Yak - 🐂'],
  'Z': ['Zebra - 🦓', 'Zipper - 🔗', 'Zucchini - 🥒'],
};
  return examples[letter] ?? [];
}